home *** CD-ROM | disk | FTP | other *** search
- import java.awt.Button;
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Container;
- import java.awt.Dialog;
- import java.awt.Event;
- import java.awt.FlowLayout;
- import java.awt.Font;
- import java.awt.Frame;
- import java.awt.Rectangle;
-
- public class QuitDialog extends Dialog {
- Button yesButton;
- Button noButton;
-
- void yesButton_Clicked(Event event) {
- ((Component)this).getParent().handleEvent(new Event(this, 201, (Object)null));
- }
-
- void noButton_Clicked(Event event) {
- ((Component)this).hide();
- }
-
- public QuitDialog(Frame parent, boolean modal) {
- super(parent, modal);
- ((Container)this).setLayout(new FlowLayout(1, 20, 35));
- ((Dialog)this).addNotify();
- ((Component)this).resize(((Container)this).insets().left + ((Container)this).insets().right + 317, ((Container)this).insets().top + ((Container)this).insets().bottom + 97);
- ((Component)this).setFont(new Font("Dialog", 1, 12));
- ((Component)this).setForeground(new Color(0));
- ((Component)this).setBackground(new Color(16777215));
- this.yesButton = new Button(" Yes ");
- this.yesButton.reshape(((Container)this).insets().left + 112, ((Container)this).insets().top + 35, 44, 21);
- this.yesButton.setFont(new Font("Dialog", 1, 12));
- ((Container)this).add(this.yesButton);
- this.noButton = new Button(" No ");
- this.noButton.reshape(((Container)this).insets().left + 161, ((Container)this).insets().top + 35, 39, 21);
- this.noButton.setFont(new Font("Dialog", 1, 12));
- ((Container)this).add(this.noButton);
- ((Dialog)this).setTitle("Really Quit?");
- ((Dialog)this).setResizable(false);
- }
-
- public QuitDialog(Frame parent, String title, boolean modal) {
- this(parent, modal);
- ((Dialog)this).setTitle(title);
- }
-
- public synchronized void show() {
- Rectangle bounds = ((Component)this).getParent().bounds();
- Rectangle abounds = ((Component)this).bounds();
- ((Component)this).move(bounds.x + (bounds.width - abounds.width) / 2, bounds.y + (bounds.height - abounds.height) / 2);
- super.show();
- }
-
- public boolean handleEvent(Event event) {
- if (event.id == 201) {
- ((Component)this).hide();
- return true;
- } else {
- if (event.target == this.noButton && event.id == 1001) {
- this.noButton_Clicked(event);
- }
-
- if (event.target == this.yesButton && event.id == 1001) {
- this.yesButton_Clicked(event);
- }
-
- return super.handleEvent(event);
- }
- }
- }
-